<%@ page pageEncoding="UTF-8"%>
<%@ include file="import.jsp"%>
<%!
	// 新增数量
	public int newOperate(Map<String, String> parameters) {
		List<Integer> list = QBuilder.db("basedb").queryHql("from Order where hospital =" + parameters.get("hospital") + " and CONCAT(FROM_UNIXTIME(registerTime / 1000, '%Y-%m-%d'), '') = '" + parameters.get("date") + "' and state = " + STATE_ADD + " and status = " + STATUS_ENABLE);
		return list.size();
	}

	// 手术安排
	public int hasOperate(Map<String, String> parameters, Token token) {
		List<Integer> list = QBuilder.db("basedb").queryHql("from Order where hospital =" + parameters.get("hospital") + " and CONCAT(FROM_UNIXTIME(execTime / 1000, '%Y-%m-%d'), '') = '" + parameters.get("date") + "' and state = " + STATE_HANDLED + " and status = " + STATUS_ENABLE + " and doctor = " + token.getUid());
		return list.size();
	}

	// 复诊随访
	public int followVisit(Map<String, String> parameters, Token token) {
		List<Integer> list = QBuilder.db("basedb").queryHql("from Visit where hospital =" + parameters.get("hospital") + " and checkTime = '" + parameters.get("date") + "' and status = " + STATUS_ENABLE + " and isconfirmed = 1 and category = 2 and doctorUid = " + token.getUid());
		return list.size();
	}

	// 问卷随访
	public int surveyVisit(Map<String, String> parameters, Token token) {
		List<Integer> list = QBuilder.db("basedb").queryHql("from Visit where hospital =" + parameters.get("hospital") + " and sendTime = '" + parameters.get("date") + "' and status = " + STATUS_ENABLE + " and category = 3 and doctorUid = " + token.getUid());
		return list.size();
	}

	// 分组下的所有人数(去掉了patientUid为空的记录)
	public int patients(Map<String, String> parameters, Token token) {
		List<Integer> list = QBuilder.db("basedb").queryHql("from GroupPatient as gp, DoctorGroup as dg where gp.hospital =" + parameters.get("hospital") + " and gp.status = " + STATUS_ENABLE + " and gp.patientUid is not null and dg.hospital =" + parameters.get("hospital") + " and dg.status = " + STATUS_ENABLE + " and dg.doctorUid = " + token.getUid() + " and gp.groupId = dg.id group by gp.patientUid");
		return list.size();
	}
%>
